<template>
  <div style="margin-left: 100px;width: 80%;border: 1px slategray solid;">
    <el-menu mode="horizontal">
      <el-menu-item index="1" @click="submit">提交</el-menu-item>
      <el-menu-item index="2">终止</el-menu-item>
    </el-menu>
    <el-form size="mini" v-model="value" style="padding-top: 10px;">
      <div v-for="(item,index) in formStyle" :key="index">
        <el-form-item align="left" :label="item.name" :prop="item.name" label-width="100px">
          <el-input v-model="value[item.name]" style="width: 200px" :disabled="isDisabled(item)"/>
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "FormEngine",
  props: ["data", "formStyle", "taskKey"],
  watch: {
    "data": {
      handler() {
        this.value = {...this.data}
      },
    }
  },
  data() {
    return {
      from: [-1],
      value: {}
    }
  },
  methods: {
    isDisabled(value) {
      return value.stint !== this.taskKey
    },
    submit() {
      this.$emit("submit", this.value)
    }
  }
}
</script>

<style scoped>

</style>